#ifndef _DSWONVIF_CENTER_H
#define _DSWONVIF_CENTER_H

#include "base.h"

#include "dswonvif_session.h"

typedef struct
{
	char username[64];
	char password[32];
} UserInfo_S;

class CDswonvif_center
{
public:
	CDswonvif_center(LPST_ENV_T pEnv);
	virtual ~CDswonvif_center();
public:
	void StartDescover();
	void StopDescover();
	int GetDescoverResult(void* pResult);
private:
	void ONVIF_GenrateDigest(unsigned char *pwddigest_out, unsigned char *pwd, char *nonc, char *time);
	struct soap* ONVIF_Initsoap(struct SOAP_ENV__Header *header, const char *was_To, const char *was_Action, int timeout, UserInfo_S *pUserInfo);
	void ProcessDescoverResult(char* pUUID, char* pDeviceURL);
	void GetProfiles(struct soap *soap, char* pUUID, char* pMediaURL);
	void GetStreamURL(struct soap *soap, char* pMediaURL, char* profile_token);

	static void* cbDescoverThreadFunc(void* pParam){((CDswonvif_center*)pParam)->DescoverThreadFunc();return NULL;};
	void DescoverThreadFunc();
private:
	LPST_ENV_T m_pEnv;
	bool m_bStopDescover;
	pthread_t m_nDescoverThreadID;

	CDswonvif_session* m_pSession;
};

#endif

